#ifndef __SYSFIFO_H
#define __SYSFIFO_H

#ifdef __cplusplus
 extern "C" {
#endif
	 
#include <stdint.h>
#include "compiler.h"

typedef enum {
	FifoOK				= 0,
	FifoErrSizeIllegal	= 1,
	FifoErrIsEmpty		= 2,
	FifoErrIsFull		= 3,
}FifoSta_E;

typedef struct tagFifo
{
    volatile uint32_t wIdx; /* counter for FIFO input, inc in ISR only */
    volatile uint32_t rIdx; /* counter for FIFO output, inc in MAIN only */
    uint32_t size;            /* FIFO buffer size */
    uint32_t mask;            /* Mask to extract buffer index from counters */
}Fifo_T,*pFifo_T;

uint8_t Fifo_Init(pFifo_T _fifo,const uint32_t _size);
uint8_t Fifo_IsEmpty(pFifo_T _fifo);
uint8_t Fifo_IsFull(pFifo_T _fifo);
uint8_t Fifo_GetLen(pFifo_T _fifo,uint32_t *_len);
uint8_t Fifo_Get(pFifo_T _fifo, uint32_t *_index);
uint8_t Fifo_Put(pFifo_T _fifo, uint32_t *_index);



#ifdef __cplusplus
}
#endif
#endif
